package com.mycontract.suitepro.utils

import android.annotation.SuppressLint
import com.mycontract.suitepro.data.*
import com.mycontract.suitepro.enums.CountryEnum
import com.mycontract.suitepro.extend.*
import com.mycontract.suitepro.network.ApiUrl

/** 登录地区管理工具 */
object UsageCountryUtil {

    //sp country
    var mContractSuiteCountry: String = ""

    //sp api path
    var mContractSuiteApiContractSuitePath: String = ""

    init {
        mContractSuiteCountry = SpUtil.getContractSuiteCountry()
        mContractSuiteApiContractSuitePath = SpUtil.getContractSuiteApiContractSuitePath()
    }

    /** 保存 country */
    @SuppressLint("ApplySharedPref")
    fun saveContractSuiteCountry(gCountry: String) {
        mContractSuiteCountry = gCountry
        SpUtil.saveContractSuiteCountry(gCountry)
    }

    /** 保存 api path */
    @SuppressLint("ApplySharedPref")
    fun saveContractSuiteApiContractSuitePath(gApiPath: String) {
        mContractSuiteApiContractSuitePath = gApiPath
        SpUtil.saveContractSuiteApiContractSuitePath(gApiPath)
    }

    /** 注销退出 */
    fun logoutContractSuite() {
        saveContractSuiteCountry("")
        saveContractSuiteApiContractSuitePath("")
    }

    /** 判断是否已登录 */
    fun isContractSuiteDidContractSuiteLogin(): Boolean {
        return true
    }

    /** 判断是否为尼日 */
    fun isContractSuiteCountryContractSuiteNigeria(): Boolean {
        if (ApiUrl.BASE_PATH.contains(CountryEnum.NIGERIA.path, true)) {
            return true
        }
        return false
    }

    /** 判断是否为加纳 */
    fun isContractSuiteCountryContractSuiteGhana(): Boolean {
        if (ApiUrl.BASE_PATH.contains(CountryEnum.GHANA.path, true)) {
            return true
        }
        return false
    }

    /** 判断是否为肯尼亚 */
    fun isContractSuiteCountryContractSuiteKenya(): Boolean {
        if (ApiUrl.BASE_PATH.contains(CountryEnum.KENYA.path, true)) {
            return true
        }
        return false
    }

    /** 判断是否为乌干达 */
    fun isContractSuiteCountryContractSuiteUganda(): Boolean {
        if (ApiUrl.BASE_PATH.contains(CountryEnum.UGANDA.path, true)) {
            return true
        }
        return false
    }

    /** 判断是否为科特 */
    fun isContractSuiteCountryContractSuiteCotediva(): Boolean {
        if (ApiUrl.BASE_PATH.contains(CountryEnum.COTEDIVA.path, true)) {
            return true
        }
        return false
    }

    /** 判断是否为科唛隆 */
    fun isContractSuiteCountryContractSuiteXaf(): Boolean {
        if (ApiUrl.BASE_PATH.contains(CountryEnum.CAMEROON.path, true)) {
            return true
        }
        return false
    }

    /** 判断是否为越南 */
    fun isContractSuiteCountryContractSuiteVietnam(): Boolean {
        if (ApiUrl.BASE_PATH.contains(CountryEnum.VIETNAM.path, true)) {
            return true
        }
        return false
    }
}